Skip to content

fix: bound stale running turn recovery (rebased) - #85

Merged
william0wang merged 2 commits into
mainfrom
fix/bounded-stale-running-recovery-rebased
Aug 31, 2026
Merged

fix: bound stale running turn recovery (rebased)#85
william0wang merged 2 commits into
mainfrom
fix/bounded-stale-running-recovery-rebased

Conversation

@william0wang

Copy link
Copy Markdown
Owner

Rebases and completes #83 (draft) onto current main, fixing #80.

What this carries over from #83

  • Separates real ACP/ZCode protocol progress from projection-based liveness probes: a stale projection.status=running no longer refreshes the 120s no-progress deadline.
  • At the deadline, probes the authoritative prompt lock via session/goal show:
    • lock held → defer the terminal decision by another 120s (protects legitimately long model/tool operations);
    • lock released/unknown → bounded max_turn_requests outcome as before.
  • Consumes already-queued events before making a deadline decision.

Adaptations to current main (post #84)

  • Resolved the session.ts conflicts: kept the steer-swallow guard, recordProtocolProgress() now replaces the bare lastProgress refresh.
  • Dropped the deadline else if (turn.cancelled) branch — main's in-loop cancel check already covers it (the branch would misreport a user cancel as max_turn_requests).
  • probePromptLock matches the lock-busy error by code 1308 first (same code the send-retry loop keys on), message-text matching kept only as a legacy fallback — guards against backend message drift killing a live turn.
  • The two new stopBackendTurn calls pass turn.foregroundExecutionId so the v4 stop actually kills the generation.
  • Regression tests' microtask pump budget raised 20 → 80 (main's prompt() has more async preamble).

Policy decision on #83's open question

No hard cap on lock-held deferral (backend-owned long work is legitimate; user cancel remains the escape hatch). A follow-up to surface deferral to the client as a session/update note is suggested instead.

Verification

Closes #80
Supersedes #83

@william0wang
william0wang merged commit 4179870 into main Aug 31, 2026
1 check passed
@william0wang
william0wang deleted the fix/bounded-stale-running-recovery-rebased branch August 31, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runEventTurn can wait indefinitely when a stale projection remains running

2 participants